package com.zkthink.ceres.msgs.service.impl;

import com.zkthink.base.R;
import com.zkthink.base.service.SuperServiceImpl;
import com.zkthink.ceres.info.entity.PlatformInfo;
import com.zkthink.ceres.msgs.dao.PlatformInfoMapper;
import com.zkthink.ceres.msgs.service.PlatformInfoService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 业务实现类 平台信息表
 * </p>
 *
 * @author kellen
 * @date 2020-12-30
 */
@Slf4j
@Service
@AllArgsConstructor
public class PlatformInfoServiceImpl extends SuperServiceImpl<PlatformInfoMapper, PlatformInfo> implements PlatformInfoService {

    @Autowired
    private PlatformInfoMapper platformInfoMapper;

    /**
     * 查询平台信息
     *
     * @return PlatformInfo 平台信息
     */
    @Override
    public PlatformInfo findPlatformInfo() {
        return platformInfoMapper.selectPlatformInfo();
    }

    @Override
    public R<Boolean> addPlatformInfo(PlatformInfo platformInfo) {
        PlatformInfo platformInfo1 = platformInfoMapper.selectPlatformInfo();
        if (platformInfo1 == null) {
            platformInfoMapper.insert(platformInfo);
            return R.success();
        }
        platformInfoMapper.updateById(platformInfo);
        return R.success();
    }
}
